#include "plateau.h"


Plateau::Plateau (QWidget * parent):QGraphicsView (parent)
{
    press = false;
    setBackgroundBrush(QBrush(Qt::black));
    setScene(new QGraphicsScene);
    fitInView(0,0,2048,2048, Qt::KeepAspectRatio);
}
void Plateau::resizeEvent (QResizeEvent * event)
{
    fitInView(0,0,2048,2048, Qt::KeepAspectRatio);
}
void Plateau::mousePressEvent(QMouseEvent * event)
{
    press = true;
    emit mouse(mapToScene(event->x(),event->y()));
}
void Plateau::mouseReleaseEvent(QMouseEvent * event)
{
    press = false;
}

void Plateau::mouseMoveEvent(QMouseEvent * event)
{
    if (press) emit mouse(mapToScene(event->x(),event->y()));
}

void Plateau::advance(int phase)
{
    //int t = temps.elapsed();
    //temps.restart();
    //qDebug() << ((Plateau)parent).getTimer().interval();
   // if (qrand() % 500 <= 1) ajoutEnnemi(new Fourmi(1));

   // for (unsigned int i = 0; i < ennemis.size(); i++)
   // {
       // qDebug() << (ennemis[i]->x())/128 << round((ennemis[i]->x())/128);
        //qDebug() << (ennemis[i]->y())/128 << round((ennemis[i]->y())/128);
/*
        Case& c = map[round((ennemis[i]->y())/128)][round((ennemis[i]->x())/128)];
        if (c.getArrivee())
        {
            delete ennemis[i];
            ennemis.erase(ennemis.begin()+i);
            emit perdreVie();
        }
        else
        {
            int x = 0;
            int y = 0;
            if (c.getNord()) y -= t;
            if (c.getSud()) y += t;
            if (c.getEst()) x += t;
            if (c.getOuest()) x -= t;
           ennemis[i]->avancer(x,y);
        }
        */
    //}

}



